<?php
    $ip = "localhost"; // 数据库服务器地址
    $user = "root";     // 数据库用户名
    $pwd = "123456";     // 数据库密码
    $db = "text";     // 数据库名称
    // 创建连接
    $conn = mysqli_connect($ip, $user, $pwd, $db);
    // 检查连接
    if (!$conn) {
        die("连接失败: " . $conn->connect_error);
    }
    echo "连接成功:";
 
    $name = "zhangsan";
    $password = "1596";
    $sql = "INSERT INTO test(NAME, PASSWORD) VALUES('$name', '$password')";
 
    echo $sql."\n";
 
    $result = mysqli_query($conn, $sql);
    if($result){
     echo "新增成功！";
    } else {
     echo "新增失败:".mysqli_error($conn);
    }
    # 关闭连接
    mysqli_close($conn);

?>